home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 2.3 KB | 119 lines | [TEXT/MSET] |
- \ 30Aug94 dbh added focus: response so key: messages are sent.
- \ 28Oct94 dbh updated to 2.5 syntax
-
- (*
-
- *** DESCRIPTION
-
- A 1 column list, a list-col is based on the ListManager. This is a selection
- protocol class. We treat the list as if it were a 1-dimensional array and
- use the access methods to: and at: in the expected fashion, with the address
- and length of the string being the data.
-
- *)
-
- :class list-col super{ ListManager }
-
- :m classinit:
- 0 1 put: theBounds \ start with 0 rows ( 1 column of course)
- 50 20 150 100 put: rView
- 50 put: MaxDataLen
- false put: scrollHoriz
- true put: scrollVert
- ;m
-
- :m at: ( row# -- addr len )
- 0 at: super ;m \ will return len = actual length
-
- :m to: ( addr len row# -- )
- 0 to: super ;m
-
- :m add: { addr len \ row# -- }
- \ adds one cell to the end of the list with the given text
- word0 \ room for result
- 1 \ count
- 9999 pack \ rowNum, make it large so new last rows will always be added
- get: ListHandle call LAddRow i->l -> row#
- addr len row# to: self
- row# select: [self]
- show: self
- row# deselect: [self]
- ;m
-
- :m delete: { row# -- } \ deletes the given cell
- 1 makeint ( count) row# ( rowNum) makeint
- get: ListHandle call LDelRow ;m
-
- :m selected?: ( row# -- b ) \ true if given cell is selected
- 0 false LGetSelect: self ;m
-
- :m select: ( row# -- )
- 0 select: super ;m
-
- :m deselect: ( row# -- )
- 0 deselect: super ;m
-
- :m next: { row#1 -- row#2 t | f }
- \ given a cell row#, return the next selected cell row# under true if
- \ there is a selected cell after row#1, if no more selected cells return false
- row#1 0 true LGetSelect: self
- IF
- getrow#: theCell true
- ELSE
- false
- THEN ;m
-
- :m deleteSel: { \ row# -- } \ delete only the selected rows
- false dodraw: self
- 0 -> row#
- row# selected?: self IF row# delete: self THEN
- BEGIN
- row# next: self
- WHILE
- ( row#2 ) -> row#
- row# delete: self
- REPEAT
- true dodraw: self
- ;m
-
- :m deleteAll: \ delete all cells
- BEGIN
- #rows: self \ while we have at least one row
- WHILE
- 0 delete: self \ delete it
- REPEAT ;m
-
- :m key: ( char -- )
- CASE
- 8 ( delete) OF deleteSel: self ENDOF
- ENDCASE ;m
-
- :m clear:
- deleteSel: self ;m
-
- :m focus?: ( -- true )
- true ;m
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- selwindow w
- test: w
-
- list-col l
- l add: w
-
- " hello" add: l
- " world" add: l
- " trains" add: l
- " boats" add: l
- " planes" add: l
- " hello" add: l
- " world" add: l
- " trains" add: l
- " boats" add: l
- " planes" add: l
-